﻿@model  Faurecia.WM.Web.Models.SaveProductModel
<div class="page-bar">
    <ul class="page-breadcrumb">
        <li>
            <span id="module">佛吉亚管理</span>
            <i class="fa fa-angle-right"></i>
        </li>
        <li>
            <span id="action"></span>
        </li>
    </ul>
</div>
<!-- END PAGE BAR -->
<div class="mt-bootstrap-tables" style="margin-top:20px">
    <div class="row">
        <div class="col-md-12">
            <div class="portlet light bordered">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="icon-social-dribbble font-green hide"></i>
                    </div>
                    <div class="actions">
                        <a class="btn btn-default" href="@Url.Action("Index")">
                            <i class="fa fa-list-ul"></i> 返回列表
                        </a>
                    </div>
                </div>

                <div class="portlet-body form">
                    <!-- BEGIN FORM-->
                    <form id="defaultForm" class="form-horizontal" method="post" novalidate="novalidate">
                        <div class="form-body">

                            @if (Model.Propertys != null && Model.Propertys.Count > 0)
                            {
                                for (var i = 0; i < Model.Propertys.Count; i++)
                                {
                                    var property = Model.Propertys[i];
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="control-label col-md-3">
                                                    <span class="required" aria-required="true">*</span>
                                                    @(property.Key)：
                                                </label>
                                                <div class="col-md-9">
                                                    <div class="input-icon right">
                                                        <i class="fa"></i>
                                                        <input type="hidden" name="@(string.Format("Propertys[{0}].KeyId",i))" value="@(property.KeyId)" />
                                                        <input type="hidden" name="@(string.Format("Propertys[{0}].Key",i))" value="@(property.Key)" />
                                                        <input type="text" name="@(string.Format("Propertys[{0}].Value", i))" value="@(property.Value)" class="form-control" maxlength="15" placeholder="不能为空" required />
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                }
                                }
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="control-label col-md-3">
                                            @*<span class="required" aria-required="true">*</span>*@
                                            预警数：
                                        </label>
                                        <div class="col-md-9">
                                            <div class="input-icon right">
                                                <i class="fa"></i>
                                                @Html.HiddenFor(x => x.Id)
                                                @Html.HiddenFor(x => x.ProductTypeId)
                                                @Html.TextBoxFor(x => x.ProductMinimumCount, new { type = "text", @class = "form-control", @maxlength = "2", @onkeyup = "inputInt(this)", @placeholder = "请输入预警数，单位：车", @min = "0", })
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-actions">
                            <div class="row">
                                <div class="col-md-offset-3 col-md-9">
                                    <button type="submit" class="btn green">保存</button>

                                    <button type="reset" class="btn">重置</button>
                                </div>
                            </div>
                        </div>
                    </form>
                    <!-- END FORM-->
                </div>
            </div>
        </div>
    </div>
</div>
@section scripts{
    <script type="text/javascript">
        customFormValidate($("#defaultForm"), {}, function (form) {
            var data = $(form).serializeObject();
            $.ajax({
                type: "POST",
                url: "@Url.Action("Save")",
                data: data,
                async: false,
                success: function (reslut) {
                    if (reslut.Success) {
                        showToast(0, '系统提示', "保存成功");
                        setTimeout(function () {
                            location.href = "@Url.Action("Index")";
                        }, 500);
                    } else {
                        showToast(3, '系统提示', reslut.Message);
                    }
                },
                error: function (error) {
                    showToast(3, '系统提示', " 操作失败!");
                }
            });
        });
    </script>

}